<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul,
        li {
            list-style: none;
        }
        a{
            text-decoration: none;
            color: black;
        }
        .box{
            width: 300px;
            height: 300px;
            border: 1px solid black;
        }
        .box>ul{
            margin-top: 5px;
        }
        .box ul li {
            font-size: 14px;
            margin-left: 5px;
        }
        section{
            display: flex;
        }
        .box section a{
            display: block;
            margin: 5px;
        }
        .s1{
            color: green;
        }
    </style>
</head>

<body>
    <div class="box">
        <section>
            <a href="#/video" class="s1">视频</a> &nbsp;&nbsp;&nbsp;<a href="#/live" class="s2">直播</a>
        </section>
        <ul>
            <li>阿VAVAVAVA啊啊啊啊</li>

        </ul>
    </div>
</body>

</html>
<script>
    var shipin=document.querySelector('.s1')
    var zhibo=document.querySelector('.s2')
    var arr1=['阿aaaaa啊啊啊啊','阿VAVAVAVA啊啊啊啊','阿V烦烦烦VA啊啊啊啊','阿V烦烦烦VA啊啊啊啊','阿V烦烦烦VA啊啊啊啊']
    var arr2=['阿aaaaddddd啊','啊啊啊啊VA啊啊啊啊','开闭不予啊','阿V烦烦烦VA啊啊啊啊','阿V烦烦烦VA啊啊啊啊',]
    //先封装渲染函数
    function shipiner(){
        document.querySelector('ul>li') .innerHTML=arr1.map((item)=>{
            return `<li>${item}</li>`
        }).join('')
    }
    function zhiboer(){
        document.querySelector('ul>li') .innerHTML=arr2.map((item)=>{
            return `<li>${item}</li>`
        }).join('')
    }
    //添加点击事件
    function dianji(){
        shipin.onclick=()=>{
            shipin.style.color='green'
            zhibo.style.color='black'
            shipiner()
        }
        zhibo.onclick=function(){
            zhibo.style.color='green'
            shipin.style.color='black'
            zhiboer()
        }
    }
    window.onhashchange=function(){
        switch( location.hash ){
                case '#/video':dianji(); break;
                case '#/live':dianji() ; break;
            }
    }
    shipiner()
    dianji()

</script>